// 引入 request 方法，假设 request 方法已经定义在某个工具文件中
import request from '/@/utils/request';
import { StressTestInput } from '../models';
// 定义 API 路径枚举
enum Api {
    SysCommonApiList = '/sysCommon/apiList',
    SysCommonDownloadErrorExcelTemp = '/sysCommon/downloadErrorExcelTemp',
    SysCommonEncryptPlainText = '/sysCommon/encryptPlainText/{plainText}',
    SysCommonSmKeyPair = '/sysCommon/smKeyPair',
    SysCommonStressTest = '/sysCommon/stressTest',
}

// 定义 API 方法
/**
 * 获取所有接口/动态API 🔖
 */
export const apiSysCommonApiListGet = () =>
    request({
        url: Api.SysCommonApiList,
        method: 'get',
    });

/**
 * 下载标记错误的临时Excel（全局）
 * @param fileName 文件名
 */
export const apiSysCommonDownloadErrorExcelTempPost = (fileName?: string) =>
    request({
        url: Api.SysCommonDownloadErrorExcelTemp,
        method: 'post',
        params: {
            fileName,
        },
    });

/**
 * 加密字符串 🔖
 * @param plainText 明文
 */
export const apiSysCommonEncryptPlainTextPlainTextPost = (plainText: string) =>
    request({
        url: Api.SysCommonEncryptPlainText.replace('{plainText}', encodeURIComponent(plainText)),
        method: 'post',
    });

/**
 * 获取国密公钥私钥对 🏆
 */
export const apiSysCommonSmKeyPairGet = () =>
    request({
        url: Api.SysCommonSmKeyPair,
        method: 'get',
    });

/**
 * 接口压测 🔖
 * @param body 请求体
 */
export const apiSysCommonStressTestPost = (body?: StressTestInput) =>
    request({
        url: Api.SysCommonStressTest,
        method: 'post',
        data: body,
    });